package locations.actions;

import javax.servlet.http.HttpServletRequest;

import locations.dao.DAOFactory;
import locations.dao.InstitutionTypeDAO;
import locations.model.InstitutionType;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class EditInstitutionTypeAction extends ActionSupport implements
		ModelDriven<InstitutionType>, ServletRequestAware {

	private static final long serialVersionUID = -8124967730231198191L;

	private HttpServletRequest request;
	private InstitutionType institutionType = new InstitutionType();

	public String execute() {
		Long id = Long.parseLong(this.getRequest().getParameter("id"));
		InstitutionTypeDAO dao = DAOFactory.getInstitutionTypeDAO();
		this.institutionType = dao.retrieveById(id);
		return SUCCESS;
	}

	public InstitutionType getInstitutionType() {
		return institutionType;
	}

	public void setInstitutionType(InstitutionType institutionType) {
		this.institutionType = institutionType;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public InstitutionType getModel() {
		return null;
	}

}
